package com.day23;

public class People {
    String name;
    String sex;
    int age;

    /**
     * 编译器默认提供的构造方法,不管写还是没写
     */
//    People(){//无参构造方法

//    }
    People(){

    }

    /**
     * 有参的构造方法（编译器不会再提供默认的构造方法）
     * @param name
     * @param sex
     * @param age
     */
    People(String name,String sex,int age){
        this.name=name;
        this.sex=sex;
        this.age=age;
    }

    //只实例化姓名
    People(String name){
        this.name=name;
    }

    //只实例化性别，年龄
    People(String sex,int age){
        this.sex=sex;
        this.age=age;
    }

    public static void main(String[] args){
        //无参构造方法调用
        People p=new People();
        System.out.println(p.name);
        System.out.println(p.sex);
        System.out.println(p.age);

        //有参构造方法调用
        People p1=new People("萌萌","女",25);
        System.out.println(p1.name+","+p1.sex+","+p1.age);

        //只调用姓名
        People p2=new People("萌萌");
        System.out.println(p2.name);

        //只调用性别，年龄
        People p3=new People("女",25);
        System.out.println(p3.sex+","+p3.age);
    }
}
